#!-*- encoding:utf8 -*-
from django.db import models
from newosmp.host.models import Product, Host
from newosmp.define import *

# Create your models here.

class Monitor(models.Model):
    name = models.CharField(max_length=50, unique=True)   #监控名称
    url = models.CharField(max_length=255)    #监控地址
    tpl = models.CharField(max_length=20, choices=CH_TPL) #监控模板
    freq = models.IntegerField()              #监控频率
    open = models.CharField(max_length=1, choices=CH_TRUE_FALSE) #是否开启
    status = models.CharField(max_length=1, choices=CH_TRUE_FALSE) #目前状态
    table = models.CharField(max_length=100, blank=True)    #数据表
    pid = models.ForeignKey(Product)                        #产品线
    hid = models.ForeignKey(Host)                           #主机
    alert_count = models.IntegerField(default=0)
    error_time = models.IntegerField(default=0)

    def __unicode__(self):
        return u"%s[%s]" % (self.name, self.tpl)

    def __str__(self):
        return "%s[%s]" % (self.name, self.tpl)
